import axios from '@/utils/api'

const Order = () => {
    return axios.post("http://localhost:3000/api/order")
}

// 删除
const delOrder = (id) => {
    return axios.post("http://localhost:3000/api/delOrder", { id })
}

// 修改
const updateOrder = (id, title, publishedAt, time, phone, au, state,address,num,price) => {
    return axios.post("http://localhost:3000/api/updateOrder", { id, title, publishedAt, time, phone, au, state, address ,num,price})
}

// 添加
const addOrder = (title, publishedAt, time, phone, au,  state ,address,num,price) => {
  console.log("addOrder", title, publishedAt, time, phone, au,  state,address,num,price);

    return axios.post("http://localhost:3000/api/addOrder", { title, publishedAt, time, phone, au, state ,address,num,price})
}
// 筛选
const selectOrder = (title, au, phone, state,address,num,price) => {
    const query = { title, au, phone, state,address,num,price};
    const filterQuery = Object.fromEntries(
        Object.entries(query).filter(([key, value]) => value)
    );
    return axios.post("http://localhost:3000/api/selectOrder", { filterQuery })
}


export { Order, delOrder, updateOrder, addOrder, selectOrder }
